/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tsb.arrastrar;

import java.awt.*;
import java.awt.geom.Line2D;


public class Conexion {
    
   
    public static final int ethernetRJ45=1;
    public static final int fibra=2;
    public static final int serial=3;
    public static final int ethernetRJ11=4;
    public static final int wireles=5;
    
    private Point ini, fin;
    private int tipo;
    
    public Conexion(int tipo, Point ini, Point fin) {
        this.tipo=tipo;
        this.ini=ini;
        this.fin=fin;
    }
    public Conexion(){
        this(Conexion.ethernetRJ45, new Point(), new Point());
    }
    public Conexion(int tipo){
        this(tipo, new Point(), new Point());
    }

    public Point getFin() {
        return fin;
    }

    public void setFin(Point fin) {
        this.fin = fin;
    }

    public Point getIni() {
        return ini;
    }

    public void setIni(Point ini) {
        this.ini = ini;
    }
    
    
    //mientras sedibuja la figura
    public void dibujar(Graphics g, Point ini, Point fin){
        this.ini=ini;
        this.fin=fin;
        Graphics2D g2d = ( Graphics2D ) g;
       
        
        switch(tipo)
        {
            case 1: 
                g2d.setPaint( new Color(0, 255, 0));//verde
                break;
            case 2:
                g2d.setPaint( new Color(0,0,255));//Azul
                break;
            case 3: 
                g2d.setPaint( new Color(204,0,0));//Bordo
                break;
            case 4:
                g2d.setPaint( new Color(153,153,153));//Gris
                break;
            case 5:
                g2d.setPaint( new Color(255,153,255));//Rosa
                break;
        }
        
        //g2d.setPaint( this.color);
        float guiones[] = { 1 };
        g2d.setStroke( new BasicStroke( 4, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 10, guiones, 0 ) );
        g2d.draw( new Line2D.Double( ini.x, ini.y, fin.x, fin.y ) );
        

        
    }
    
    //figura final
    public void dibujar(Graphics g){
        dibujar(g, ini, fin);
    }

    public void borrar(Graphics g)
    {
        (( Graphics2D )g).clearRect(ini.x, ini.y, fin.x, fin.y);
    }
}

